<?php
class Default_Model_DbTable_Partner extends Zend_Db_Table_Abstract {
	protected $_name = 'partner';
	public function addPartner($partner_name, $logo, $dateon, $dateoff, $description, $position, $status) {
		$data = array (
				'PARTNER_NAME' => $partner_name,
				'LOGO' => $logo,
				'DATEON' => $dateon,
				'DATEOFF' => $dateoff,
				'DESCRIPTION' => $description,
				'POSITION' => $position,
				'STATUS' => $status 
		);
		return $this->insert ( $data );
	}
	public function updateStatus($partner_id, $status) {
		$data = array (
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $partner_id" );
	}
	public function updatePosition($partner_id, $position) {
		$data = array (
				'POSITION' => $position 
		);
		return $this->update ( $data, "ID = $partner_id" );
	}
	public function updatePartner($partner_id, $partner_name, $logo, $dateon, $dateoff, $description, $status, $position) {
		$data = array (
				'PARTNER_NAME' => $partner_name,
				'LOGO' => $logo,
				'DATEON' => $dateon,
				'DATEOFF' => $dateoff,
				'DESCRIPTION' => $description,
				'POSITION' => $position,
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID = $partner_id" );
	}
	public function getAllPartner() {
		return $this->fetchAll ()->toArray ();
	}
	public function getPartnerById($partner_id) {
		return $this->fetchRow("ID = $partner_id");
	}
	public function getPartnerByName($partner_name, $status) {
		return $this->fetchRow("PARTNER_NAME = '$partner_name' And STATUS = $status");
	}
	public function removePartner($id) {
		return $this->delete("ID = $id");
	}
	public function getPartnerByStatus($status) {
		return $this->fetchAll("STATUS = $status");
	}
	public function Active($id){
		$part = $this->getPartnerById($id);
		if($part->STATUS == 1){
			$this->update(array("STATUS"=>0), "ID = $id");
		}else{
			$this->update(array("STATUS"=>1), "ID = $id");
		}
	}
}

